package com.eos.control.action.customer;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.eos.business.service.SysProductBusinessService;
import com.eos.common.tool.ConstantTool;
import com.eos.control.action.base.AbstractBaseAction;
import com.eos.orm.mybatis.model.SysProduct;
import com.hf.utils.PaginationBean;

public class ProductTypeListAction extends AbstractBaseAction {
	private static final long serialVersionUID = -8387043470464700966L;
	private String productName;
	private Integer numPerPage;
	private Integer pageNum;
	private List<SysProduct> productList;
	private Integer totalCount;
	
	public String getProductName() {
		return productName;
	}

	public void setProductName(String productName) {
		this.productName = productName;
	}

	public Integer getNumPerPage() {
		return numPerPage;
	}

	public void setNumPerPage(Integer numPerPage) {
		this.numPerPage = numPerPage;
	}

	public Integer getPageNum() {
		return pageNum;
	}

	public void setPageNum(Integer pageNum) {
		this.pageNum = pageNum;
	}

	public List<SysProduct> getProductList() {
		return productList;
	}

	public Integer getTotalCount() {
		return totalCount;
	}

	@SuppressWarnings("unchecked")
	@Override
	public String execute() {
		try {
			Map<String, String> map = new HashMap<String, String>();
			if(pageNum == null || pageNum.intValue()==0) pageNum = 1;
			if(numPerPage == null || numPerPage.intValue() ==0) numPerPage = PAGE_SIZE;
			map.put("table_name", "sys_product");
			map.put("page_size", numPerPage+"");
			map.put("cur_page", pageNum+"");
			map.put("product_name", productName);
			map.put("deal_flag", ConstantTool.DEAL_FALG_OK);
			map.put("status", ConstantTool.STATUS_OK);
			SysProductBusinessService spbs = new SysProductBusinessService();
			PaginationBean pageBean = spbs.getSysProductList(map);
			totalCount = null != pageBean ? pageBean.getMaxcount() : 0;
			productList =  null != pageBean ? (List<SysProduct>)pageBean.getResultList() : null;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return SUCCESS;
	}
}
